class CreateRoles < ActiveRecord::Migration
  def self.up
    create_table :roles do |t|
      t.column :name, :string
      t.column :desc, :string
    end

    create_table :roles_users, :id => false do |t|
      t.column :user_id, :integer
      t.column :role_id, :integer
    end
    
    role = Role.create(:name => 'admin', :desc => 'System managers')
    Role.create(:name => 'manager', :desc => 'Todo managers')
    Role.create(:name => 'user', :desc => 'System users')
    user = User.find_by_name('boon')
    user.roles << role
    user.save
  end

  def self.down
    drop_table :roles
    drop_table :roles_users
  end
end